package com.example.helloworld;

import java.util.Calendar;
import java.util.GregorianCalendar;

public class CalendarDemo {
    public static void main(String[] args) {
        String months[] = {
                "January", "February", "March",
                "April", "May", "June", "July",
                "August", "September", "October",
                "November", "December"
        };
        int year;
        GregorianCalendar gcalendar = new GregorianCalendar();
        year = gcalendar.get(Calendar.YEAR);
        System.out.print("Current Date: " + months[gcalendar.get(Calendar.MONTH)]+ " ");
        System.out.print(gcalendar.get(Calendar.DAY_OF_MONTH)+", ");
        System.out.println(gcalendar.get(Calendar.YEAR));
        System.out.print("Current Time: " + gcalendar.get(Calendar.HOUR_OF_DAY)+":");
        System.out.print(gcalendar.get(Calendar.MINUTE)+":");
        System.out.println(gcalendar.get(Calendar.SECOND));

        // 测试是否是闰年
        if (gcalendar.isLeapYear(year)) {
            System.out.println("It is a leap year.");
        } else {
            System.out.println("It is not a leap year.");
        }
    }
}



